import java.util.Scanner;

public class Solution {
    public String truncateSentence(String s, int k){
        int len = s.length();
        int count = 0;
        int end = 0;
        for (int i = 0; i <= len; i++) {
            if(i==len || s.charAt(i) == ' '){//每遇到一个空格，count+1
                count++;
                if(count == k){
                    end = i;
                    break;
                }
            }
        }
        return s.substring(0,end);//截取子字符串作为返回值
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNext()){
            String Sen = in.nextLine();
            int k = in.nextInt();
            Solution solution = new Solution();
            String newSen = solution.truncateSentence(Sen,k);
            System.out.println(newSen);
        }
    }
}
